
//处理图表样式
function chart(data,id,type,symbol)
{
    var back = handle(data);
    var xAxis = back['xAxis'];
    var seriesData = back['seriesData'];
    //渲染图表
    var option = {
        xAxis: {
            type: 'category',
            data: xAxis
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value} '+symbol
            },
            minInterval: 1,
        },
        series: [{
            data: seriesData,
            type: type,
            barMaxWidth:30,
            "itemStyle": {
                "normal": {
                    "color": "rgba(0,191,183,1)",
                    "label": {
                        "show": true,
                        "position": "inside",

                    }
                }
            },
            label:{
                normal:{
                    color: "#555555",
                    formatter: "{c}"+symbol,
                    position:'top',
                    show: true
                }
            }
        }]
    };
    echarts.init(document.getElementById(id)).clear();
    echarts.init(document.getElementById(id)).setOption(option);
}


//处理图表数据
function handle(data)
{
    var xAxis = [];
    var seriesData = [];
    var i = 0;
    for(var k in data)
    {
        xAxis[i] = k;
        seriesData[i] = data[k];
        i++;
    }
    var back = [];
    back['xAxis'] = xAxis;
    back['seriesData'] = seriesData;
    return back
}

